package ceshiren;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.List;

public class AddressbookPage extends BasePage{
    //添加+
    private final By addbutton=By.cssSelector(".member_colLeft_top_addBtn");
    //添加部门按钮
    private final By addapartbutton=By.cssSelector(".js_create_party");
    //更多按钮中的删除
    private final By del=By.xpath ("//ul//*[text()='删除']");
//    private final By del=By.cssSelector (".vakata-context.jstree-contextmenu.jstree-default-contextmenu>li:nth-child(7)>a");

    public AddressbookPage(WebDriver basedriver) {
        super(basedriver);
    }
    public CreateApartPage addDepartment(){
        find(addbutton).click();
        find(addapartbutton).click();
        return new CreateApartPage(driver);
    }

    public void delCategoryPage(String apartname){

        ((JavascriptExecutor) driver).executeScript("document.querySelector(\".jstree-children>li:nth-child(4)>.jstree-anchor>.icon.jstree-contextmenu-hover\").click()");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        find(del).click();
    }
    public List<WebElement> getResult(String apartname){
        return finds(By.xpath("//*[@class='jstree-anchor jstree-clicked'][text()='"+apartname+"']"));

    }
}
